#ifndef MYFRAME_H
#define MYFRAME_H

#include <QFrame>
#include <QMouseEvent>
#include <QEvent>
#include <QDebug>
#include <QPainter>
#include <QLineEdit>
#include <math.h>
#include <QImage>
//temp---->
#include <iostream>
using namespace std;
//------

class MyFrame : public QFrame
{
    Q_OBJECT
public:
    explicit MyFrame(QWidget *parent = 0);
    ~MyFrame();

    void mouseMoveEvent(QMouseEvent *ev);
    void mousePressEvent(QMouseEvent *ev);
    void mouseReleaseEvent(QMouseEvent *ev);
    void leaveEvent(QEvent *);
    void enterEvent(QEvent *);

    void setDraw(); //set to promote drawing rect
    void setPositions(int, int, int, int, QLineEdit *, QLineEdit *);    //drawing rect
    void setBackgroundImage(QImage);
    void removeBackgroundImage();
    bool isImage(); //true if image is open else false
    void drawSearchresult(int**,int);   //contain coordinates of search result

    int x, y, startX, startY, endX, endY; //startX, startY, endX, endY position of rect;
    
signals:
    void mouseOn();
    void mousePressed();
    void mouseExit();
    void mouseEntered();
    void mouseLeaved();
    
public slots:

protected:
    void paintEvent(QPaintEvent *); //paint method
    QImage resizeImage(QImage);  //resize an image to the actual sizes
    bool startSearch(); //start drawing rectangel

    bool drawing, searchIsValid;   //draw rect
    QImage *image;  //background image

    int imageStartWidth, imageStartHeight, imageEndWidth, imageEndHeight;   //image start, end position on display

    int **coord, n; //contain search results;

};

#endif // MYFRAME_H
